package com.cskaoyan.javase.oop3._2inner._3local._4life;

/**
 * @description: 局部变量和对象的生命周期冲突
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class Demo {
    public static void main(String[] args) {
        EnclosedClazz ec = new EnclosedClazz();
        A innerClazz = ec.test();
        innerClazz.method();
    }
}

class EnclosedClazz {
    public A test() {
        int a = 10;
        class Inner implements A {
            @Override
            public void method() {
                System.out.println("我是接口A的子类");
                System.out.println(a);
            }
        }
        System.out.println(a);
        Inner i = new Inner();
        return i;
    }
}

interface A{
    void method();
}
